main(n,m,l){for(gets(&n);~scanf("%d%d",&n,&m);printf("%d\n",n*(n+1)/2*m*(m+1)/2-l*(l+1)*(2*l+1)/6-abs(m-n)*l*(l+1)/2))l=m<n?m:n;}
